package com.itheima.d6_object_stream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;

/*
  目标：掌握对象字节输出流的使用：序列化对象。
 */
public class Test1ObjectOutputStream {
    public static void main(String[] args) throws Exception {
        FileOutputStream fos = new FileOutputStream("object.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        User u = new User("jack", "123456","帅比");
        User e = new User("jafffk", "1fff23456","每笔");
        ArrayList<User> list = new ArrayList<>();
        Collections.addAll(list, u, e);
        oos.writeObject(list);
        oos.close();

    }

}
